//
//  CLReadLongPressView.h
//  CLBrowser
//
//  Created by 梁慧聪 on 2022/8/15.
//

#import "CLReadView.h"
#import "CLReadLongPressCursorView.h"
#import "CLMagnifierView.h"
/// Pan手势状态

typedef NS_ENUM(NSInteger, CLPanGesStatus) {
    CLPanGesStatusBegin,
    CLPanGesStatusChanged,
    CLPanGesStatusEnd
};


/// 长按阅读视图通知 info 数据 key
static NSString *CL_READ_KEY_LONG_PRESS_VIEW = @"CL_READ_KEY_LONG_PRESS_VIEW";

/// 长按阅读视图通知
static NSString *CL_READ_NOTIFICATION_LONG_PRESS_VIEW = @"CL_READ_LONG_PRESS_VIEW_NOTIFICATION";

/// 光标拖拽触发范围
#define CL_READ_LONG_PRESS_CURSOR_VIEW_OFFSET  -CL_SPACE_20


/// 监控阅读长按视图通知
static void CL_READ_NOTIFICATION_MONITOR(id target, SEL action) {
    
    [[NSNotificationCenter defaultCenter] addObserver:target selector:action name:CL_READ_NOTIFICATION_LONG_PRESS_VIEW object:nil];
}

/// 发送阅读长按视图通知
static void CL_READ_NOTIFICATION_PUSH(NSDictionary *userInfo) {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:CL_READ_NOTIFICATION_LONG_PRESS_VIEW object:nil userInfo:userInfo];

}

/// 移除阅读长按视图通知
static void CL_READ_NOTIFICATION_REMOVE(id target) {
    
    [[NSNotificationCenter defaultCenter] removeObserver:target name:CL_READ_NOTIFICATION_LONG_PRESS_VIEW object:nil];

}


NS_ASSUME_NONNULL_BEGIN

@interface CLReadLongPressView : CLReadView
/// 开启拖拽
@property (nonatomic, assign) BOOL isOpenDrag;

/// 选中区域
@property (nonatomic, assign) NSRange selectRange;

/// 选中区域CGRect数组
@property (nonatomic, strong) NSArray <NSValue *>*rects;

/// 长按
@property (nonatomic, strong, nullable) UILongPressGestureRecognizer *longGes;

/// 单击
@property (nonatomic, strong, nullable) UITapGestureRecognizer *tapGes;

/// 左光标
@property (nonatomic, strong) CLReadLongPressCursorView *LCursorView;

/// 右光标
@property (nonatomic, strong) CLReadLongPressCursorView *RCursorView;

/// 触摸的光标是左还是右
@property (nonatomic, assign) BOOL isCursorLorR;//默认true

/// 是否触摸到左右光标
@property (nonatomic, assign) BOOL isTouchCursor;

/// 动画时间
@property (nonatomic, assign) NSTimeInterval duration;//CL_READ_AD_TIME

/// 放大镜
@property (nonatomic, strong, nullable) CLMagnifierView *magnifierView;

/// 解析触摸事件
- (void)drag:(CLPanGesStatus)status point:(CGPoint)point windowPoint:(CGPoint)withPoint;
@end

NS_ASSUME_NONNULL_END
